﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Composite.Modularity;
using DevFX.Infrastructure;

namespace DevFX
{
    public class Bootstrapper : UnityBootstrapper
    {
        protected override void ConfigureContainer()
        {
            Container.RegisterType<IShellProvider, Shell>();

            base.ConfigureContainer();
        }

        protected override DependencyObject CreateShell()
        {
            IShellProvider shellProvider = Container.Resolve<IShellProvider>();
            UIElement theShell = shellProvider.CreateShell();

#if SILVERLIGHT
            App.Current.RootVisual = theShell;
#else
            (theShell as Window).Show();
#endif

            return theShell as DependencyObject;
        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            ModuleCatalog catalog;

#if SILVERLIGHT
            catalog = ModuleCatalog.CreateFromXaml(new Uri("/DevFX;component/ModulesCatalog.xaml", UriKind.Relative));
#else
            catalog = new ConfigurationModuleCatalog();
#endif

            return catalog as IModuleCatalog;
        }
    }
}
